package com.xsd.awen.web;

import com.xsd.awen.config.WebResult;
import com.xsd.awen.domain.entity.User;
import com.xsd.awen.domain.vo.UserVo;
import com.xsd.awen.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class ControllerTpl extends BaseController{

    @Autowired
    UserService userService;

    @PostMapping("page")
    public String page(UserVo userVo){
        return WebResult.page(userService.page(userVo));
    }

    @PostMapping("add")
    public String add(User user){
        return userService.save(user);
    }

    @PostMapping("update")
    public String update(User user){
        return userService.update(user);
    }

    @PostMapping("delete")
    public String delete(User user){
        return userService.delete(user);
    }

    @PostMapping("get")
    public String get(User user){
        return WebResult.OK(userService.getById(user.getId()));
    }

}